home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / drivers1.zip / AR450.ASM < prev    next >
Assembly Source File  |  1992-01-23  |  17KB  |  774 lines

  1. ;History:6,1
  2. version    equ    0
  3.  
  4.     include    defs.asm
  5.  
  6. ;  Copyright, 1991-1992, Russell Nelson, Crynwr Software
  7.  
  8. ;   This program is free software; you can redistribute it and/or modify
  9. ;   it under the terms of the GNU General Public License as published by
  10. ;   the Free Software Foundation, version 1.
  11. ;
  12. ;   This program is distributed in the hope that it will be useful,
  13. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;   GNU General Public License for more details.
  16. ;
  17. ;   You should have received a copy of the GNU General Public License
  18. ;   along with this program; if not, write to the Free Software
  19. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21. arlan_segment    segment at 0
  22.  
  23.         org    000h
  24. ar_signature    db    ?
  25.  
  26.         org    030h
  27. ar_reset    db    ?
  28.  
  29.         org    031h
  30. ar_diagnostics    db    ?
  31.  
  32.         org    040h
  33. ar_node_id    db    EADDR_LEN dup(?)    ;6 byte node address field.
  34.  
  35.         org    046h
  36. ar_node_bcast    db    EADDR_LEN dup(?)    ;6 byte broadcast address.
  37.  
  38.         org    04ch
  39. ar_type        db    ?        ;1 byte hardware type
  40. ar_type_A450    equ    00h
  41. ar_type_A650    equ    01h
  42. ar_type_A670    equ    0bh
  43. ar_type_A670E    equ    0ch
  44. ar_type_A650E    equ    0dh
  45. ar_type_A440LT    equ    0eh
  46.  
  47.         org    04dh
  48. ar_version    label    word        ;Version number.
  49. ar_version_maj    db    ?
  50. ar_version_min    db    ?
  51.  
  52.         org    080h
  53. ar_interrupt    db    ?        ;not used by LANCPU
  54.  
  55.         org    081h
  56. ar_control_i    db    ?        ;image of the control register.
  57.  
  58.         org    090h
  59. ar_command    db    ?
  60.  
  61. COM_CONF    equ    1
  62. COM_RX_ENABLE    equ    3
  63. COM_RX_ABORT    equ    4
  64. COM_TX_ENABLE    equ    5
  65. COM_TX_ABORT    equ    6
  66. COM_NOP        equ    7
  67. COM_INT        equ    80h
  68.  
  69.         org    0a0h
  70. ar_rx_status    db    ?
  71.  
  72.         org    0a2h
  73. ar_rx_offset    dw    ?        ;start of received datagram
  74.  
  75.         org    0a4h
  76. ar_rx_length    dw    ?        ;length of received datagram
  77.  
  78.         org    0a6h
  79. ar_rx_src    db    EADDR_LEN dup(?)    ;RX source address.
  80.  
  81.         org    0ach
  82. ar_rx_bcast    db    ?        ;<>0 if received frame was bcast.
  83.  
  84.         org    0adh
  85. ar_rx_quality    db    ?        ;indicates quality of received packet.
  86.  
  87.         org    0b0h
  88. ar_tx_status    db    ?
  89.  
  90.         org    0b1h
  91. ar_tx_quality    db    ?
  92.  
  93.         org    100h
  94. ar_sys_params    label    byte
  95.  
  96.         org    108h
  97. ar_irq_level    db    ?        ;IRQ level
  98.  
  99.         org    109h
  100. ar_spreading    db    3 dup(?)    ;Spread spectrum code ID.
  101.  
  102.         org    10ch
  103. ar_NID        dw    ?        ;Radio address of LAN card.
  104.  
  105.         org    11dh
  106. ar_tx_atten    db    ?        ;attenuation of radio transmitter in db.
  107.  
  108.         org    11eh
  109. ar_system_id    dd    ?        ;system ID.
  110.  
  111.         org    128h
  112. ar_MDS        dw    ?        ;Maximum Datagram Size.
  113.  
  114.         org    12ah
  115. ar_MFS        dw    ?        ;Maximum Frame Size.
  116.  
  117.         org    12ch
  118. ar_max_retry    db    ?
  119.  
  120.         org    162h
  121. ar_register    db    ?        ;indicates if card must register w/ router.
  122.  
  123.         org    164h
  124. ar_poll_rate    dw    ?        ;<>0 if power saving is used.
  125.  
  126.         org    166h
  127. ar_refresh_rate    dw    ?        ;tens of msecs between registration
  128.                     ;refreshes.
  129.         org    168h
  130. ar_name        db    16 dup(?)
  131.  
  132.         org    400h
  133. ar_tx_buffer    label    byte
  134.  
  135.         org    0c00h
  136. ar_rx_buffer    label    byte
  137.  
  138.         org    1fffh
  139. ar_control    db    ?
  140. CONTROL_RESET    equ    1
  141. CONTROL_CA    equ    2
  142. CONTROL_IE    equ    4
  143. CONTROL_CLRI    equ    8
  144.  
  145.  
  146. arlan_segment    ends
  147.  
  148. code    segment    word public
  149.     assume    cs:code, ds:code
  150.  
  151.     public    int_no
  152. int_no    db    0,0,0,0            ;must be four bytes long for get_number.
  153.  
  154. base_addr    dw    ?        ;The base address of the board.
  155.  
  156. xmit_bdcast    db    ?
  157.  
  158.     public    driver_class, driver_type, driver_name, driver_function, parameter_list
  159. driver_class    db    BLUEBOOK,0    ;from the packet spec
  160. driver_type    db    99        ;from the packet spec
  161. driver_name    db    'ARLAN 450',0    ;name of the driver.
  162. driver_function    db    2
  163. parameter_list    label    byte
  164.     db    1    ;major rev of packet driver
  165.     db    9    ;minor rev of packet driver
  166.     db    14    ;length of parameter list
  167.     db    EADDR_LEN    ;length of MAC-layer address
  168.     dw    GIANT    ;MTU, including MAC headers
  169.     dw    MAX_MULTICAST * EADDR_LEN    ;buffer size of multicast addrs
  170.     dw    0    ;(# of back-to-back MTU rcvs) - 1
  171.     dw    0    ;(# of successive xmits) - 1
  172. int_num    dw    0    ;Interrupt # to hook for post-EOI
  173.             ;processing, 0 == none,
  174.  
  175.     public    rcv_modes
  176. rcv_modes    dw    4        ;number of receive modes in our table.
  177.         dw    0,0,0,rcv_mode_3
  178.  
  179.     public    as_send_pkt
  180. ; The Asynchronous Transmit Packet routine.
  181. ; Enter with es:di -> i/o control block, ds:si -> packet, cx = packet length,
  182. ;   interrupts possibly enabled.
  183. ; Exit with nc if ok, or else cy if error, dh set to error number.
  184. ;   es:di and interrupt enable flag preserved on exit.
  185. as_send_pkt:
  186.     ret
  187.  
  188.     public    drop_pkt
  189. ; Drop a packet from the queue.
  190. ; Enter with es:di -> iocb.
  191. drop_pkt:
  192.     assume    ds:nothing
  193.     ret
  194.  
  195.     public    xmit
  196. ; Process a transmit interrupt with the least possible latency to achieve
  197. ;   back-to-back packet transmissions.
  198. ; May only use ax and dx.
  199. xmit:
  200.     assume    ds:nothing
  201.     ret
  202.  
  203.  
  204.     include    timeout.asm
  205.     include    movemem.asm
  206.  
  207.     public    send_pkt
  208. send_pkt:
  209. ;enter with es:di->upcall routine, (0:0) if no upcall is desired.
  210. ;  (only if the high-performance bit is set in driver_function)
  211. ;enter with ds:si -> packet, cx = packet length.
  212. ;if we're a high-performance driver, es:di -> upcall.
  213. ;exit with nc if ok, or else cy if error, dh set to error number.
  214.     assume    ds:nothing
  215.  
  216.     mov    es,base_addr
  217.     assume    es:arlan_segment
  218.  
  219.     cmp    cx,ar_MDS        ;Is this packet too large?
  220.     mov    dh,NO_SPACE
  221.     ja    send_pkt_toobig        ;yes, don't bother sending it.
  222.  
  223.   if 0
  224.     mov    bx,2            ;count the number of times around...
  225. wait_again:
  226.     mov    ax,10            ;don't wait too long...
  227.     call    set_timeout
  228. wait_for_xmit:
  229.     sti
  230.     cmp    ar_tx_status,0        ;is the transmit done?
  231.     jne    xmit_done        ;yes, exit now.
  232.     call    do_timeout
  233.     jne    wait_for_xmit        ;no, wait for it to finish.
  234.     cli
  235.  
  236.     inc    ar_interrupt        ;note that we had to crap out.
  237.  
  238.     mov    ar_command,COM_TX_ABORT
  239.     call    doca
  240.     mov    ar_tx_status,1
  241.   else
  242.     sti
  243. wait_for_xmit:
  244.     cmp    ar_tx_status,0        ;is the transmit done?
  245.     jne    xmit_done        ;yes, exit now.
  246.     jmp    wait_for_xmit        ;no, wait for it to finish.
  247.   endif
  248.     clc                ;pretend we actually sent it.
  249.     ret
  250. send_pkt_toobig:
  251.     stc
  252.     ret
  253. xmit_done:
  254.     cli
  255.  
  256.     mov    di,offset ar_command + 5
  257.  
  258.     mov    xmit_bdcast,0
  259.  
  260. ;check to see if it's an Ethernet broadcast (all ones).
  261.     push    ds
  262.     push    si
  263.     push    cx
  264.     mov    cx,EADDR_LEN
  265. send_pkt_1:
  266.     lodsb
  267.     cmp    al,0ffh
  268.     loope    send_pkt_1
  269.     jne    send_pkt_2        ;not Ethernet broadcast.
  270.  
  271.     inc    xmit_bdcast        ;remember that it was a broadcast.
  272.  
  273.     mov    si,offset ar_node_bcast    ;use our broadcast address.
  274.     mov    ds,base_addr
  275.  
  276.     movsw                ;move the broadcast address over.
  277.     movsw
  278.     movsw
  279.  
  280.     pop    cx
  281.     pop    si
  282.     pop    ds
  283.  
  284.     add    si,EADDR_LEN        ;skip the addresses.
  285.     jmp    short send_pkt_3
  286. send_pkt_2:
  287.     pop    cx
  288.     pop    si
  289.     pop    ds
  290.  
  291.     movsw                ;move the destination address over.
  292.     movsw
  293.     movsw
  294.  
  295. send_pkt_3:
  296.     add    si,EADDR_LEN        ;skip the addresses.
  297.     sub    cx,EADDR_LEN+EADDR_LEN    ;. .
  298.  
  299.     mov    di,offset ar_tx_buffer
  300.     mov    al,xmit_bdcast
  301.     stosb
  302.     push    cx
  303.     call    movemem
  304.     pop    cx
  305.  
  306.     inc    cx            ;include the broadcast byte.
  307.  
  308.     mov    ar_command,COM_TX_ENABLE
  309.     mov    word ptr ar_command[1],offset ar_tx_buffer
  310.     mov    word ptr ar_command[3],cx
  311.  
  312.     mov    ar_tx_status,0        ;let the board fill it in.
  313.  
  314.     call    doca
  315.  
  316.     clc
  317.     ret
  318.  
  319.  
  320.     public    get_address
  321. get_address:
  322. ;get the address of the interface.
  323. ;enter with es:di -> place to get the address, cx = size of address buffer.
  324. ;exit with nc, cx = actual size of address, or cy if buffer not big enough.
  325.     assume    ds:code
  326.     cmp    cx,EADDR_LEN        ; Caller wants a reasonable length?
  327.     jb    get_addr_x        ; No, fail.
  328.     mov    cx,EADDR_LEN        ; Move one ethernet address from our copy
  329.     mov    si,offset ar_node_id    ; Copy from the board.
  330.     push    ds
  331.     mov    ds,base_addr
  332.     rep     movsb
  333.     pop    ds
  334.     mov    cx,EADDR_LEN        ; Tell caller how many bytes we fed him
  335.     clc                ; Carry off says success
  336.     ret
  337. get_addr_x:
  338.     stc                ; Tell caller our addr is too big for him
  339.     ret
  340.  
  341.  
  342.     public    set_address
  343. set_address:
  344. ;enter with ds:si -> Ethernet address, CX = length of address.
  345. ;exit with nc if okay, or cy, dh=error if any errors.
  346.     assume    ds:nothing
  347.     ret
  348.  
  349.  
  350. rcv_mode_3:
  351. ;receive mode 3 is the only one we support, so we don't have to do anything.
  352.     ret
  353.  
  354.  
  355.     public    set_multicast_list
  356. set_multicast_list:
  357. ;enter with ds:si ->list of multicast addresses, cx = number of addresses.
  358. ;return nc if we set all of them, or cy,dh=error if we didn't.
  359.     mov    dh,NO_MULTICAST
  360.     stc
  361.     ret
  362.  
  363.  
  364.     public    terminate
  365. terminate:
  366.     clc
  367.     ret
  368.  
  369.     public    reset_interface
  370. reset_interface:
  371. ;reset the interface.
  372.     assume    ds:code
  373.     ret
  374.  
  375.  
  376. ;called when we want to determine what to do with a received packet.
  377. ;enter with cx = packet length, es:di -> packet type, dl = packet class.
  378.     extrn    recv_find: near
  379.  
  380. ;called after we have copied the packet into the buffer.
  381. ;enter with ds:si ->the packet, cx = length of the packet.
  382.     extrn    recv_copy: near
  383.  
  384.     extrn    count_in_err: near
  385.     extrn    count_out_err: near
  386.  
  387.     public    recv
  388. recv:
  389. ;called from the recv isr.  All registers have been saved, and ds=cs.
  390. ;Upon exit, the interrupt will be acknowledged.
  391.     assume    ds:code, es:arlan_segment
  392.     mov    es,base_addr
  393.  
  394. ;clear the interrupt request.
  395.  
  396.     mov    al,ar_control_i    ;drop the clear interrupt bit.
  397.     and    al,not CONTROL_CLRI
  398.     mov    ar_control,al
  399.     or    al,CONTROL_CLRI        ;raise the clear interrupt bit.
  400.     mov    ar_control,al
  401.  
  402.     cmp    ar_rx_status,0        ;was this our receive interrupt?
  403.     jne    recv_recv
  404.     cmp    ar_tx_status,0        ;was this our transmit interrupt?
  405.     jne    recv_xmit
  406.     jmp    recv_exit
  407. recv_xmit:
  408.     jmp    recv_exit
  409.  
  410. recv_recv:
  411.     mov    di,ar_rx_offset        ;get a pointer to the packet.
  412.     mov    cx,ar_rx_length        ;get the length.
  413.     dec    cx            ;omit the "was broadcast" flag.
  414.     inc    di            ;. .
  415.     add    cx,EADDR_LEN+EADDR_LEN    ;add the two headers in.
  416.     push    es
  417.     push    di
  418.     push    cx
  419.     mov    dl, BLUEBOOK        ;assume bluebook Ethernet.
  420.     call    recv_find
  421.     pop    cx
  422.     pop    si
  423.     pop    ds
  424.     assume    ds:arlan_segment, es:nothing
  425.  
  426.     mov    ax,es            ;is this pointer null?
  427.     or    ax,di
  428.     je    recv_free        ;yes - just free the frame.
  429.  
  430.     push    es
  431.     push    di
  432.     push    cx
  433.     sub    cx,EADDR_LEN+EADDR_LEN
  434.     mov    al,ds:[si-1]        ;get the "was broadcast" flag.
  435.     cmp    al,0            ;was it a broadcast?
  436.     je    recv_us            ;no.
  437.     mov    ax,0ffffh        ;yes, stuff an Ethernet broadcast in.
  438.     stosw
  439.     stosw
  440.     stosw
  441.     jmp    short recv_source
  442. recv_us:
  443.     mov    si,offset ar_node_id
  444.     movsw
  445.     movsw
  446.     movsw
  447. recv_source:
  448.     mov    si,offset ar_rx_src    ;move the source address over.
  449.     movsw
  450.     movsw
  451.     movsw
  452.     mov    si,ar_rx_offset        ;get a pointer to the packet.
  453.     inc    si
  454.     rep    movsb
  455.     pop    cx
  456.     pop    si
  457.     pop    ds
  458.     assume    ds:nothing
  459.  
  460.     call    recv_copy
  461.  
  462. recv_free:
  463.  
  464.     push    cs
  465.     pop    ds
  466.     assume    ds:code
  467.     mov    es,base_addr
  468.     assume    es:arlan_segment
  469.  
  470. enable_receive:
  471.  
  472.     mov    ar_rx_status,0        ;clear the current status.
  473.     mov    ar_command,COM_RX_ENABLE+COM_INT
  474.     mov    ar_command+1,1        ;receive broadcasts.
  475.     call    doca
  476.  
  477.     cmp    ar_rx_status,0        ;is there another packet?
  478.     jne    recv_recv        ;yes, receive it now.
  479.  
  480. recv_exit:
  481.     ret
  482.  
  483.  
  484.     public    recv_exiting
  485. recv_exiting:
  486. ;called from the recv isr after interrupts have been acknowledged.
  487. ;Only ds and ax have been saved.
  488.     assume    ds:nothing
  489.     ret
  490.  
  491. doca:
  492. ;toggle the CA bit in the control register.
  493. ;must be executed with interrupts off to protect ar_control_i.
  494. ;return cy if we had a horrible failure.
  495.     assume    es:arlan_segment
  496.     pushf                ;make up a fake iret stack frame.
  497.     cli
  498.     mov    al,ar_control_i    ;toggle the bit in the image
  499.     xor    al,CONTROL_CA
  500.     mov    ar_control_i,al    ;and store them both.
  501.     mov    ar_control,al
  502.     popf
  503.  
  504.     mov    ax,5            ;wait about 1/7th of a second.
  505.     call    set_timeout
  506. doca_2:
  507.     cmp    ar_command,0        ;wait for the command to finish.
  508.     je    doca_1            ;it did.
  509.     call    do_timeout
  510.     jne    doca_2
  511.     stc
  512.     ret
  513. doca_1:
  514.     clc
  515.     ret
  516.  
  517. ;any code after this will not be kept after initialization.
  518. end_resident    label    byte
  519.  
  520.  
  521.     extrn    error: near
  522.  
  523.     public    usage_msg
  524. usage_msg    db    "usage: ar450 [-n] [-d] [-w] <packet_int_no>",CR,LF,'$'
  525.  
  526.     public    copyright_msg
  527. copyright_msg    db    "Packet driver for an ARLAN 450, version ",'0'+(majver / 10),'0'+(majver mod 10),".",'0'+version,CR,LF
  528.         db    "Portions Copyright 1990, Russell Nelson",CR,LF,'$'
  529.  
  530.     extrn    set_recv_isr: near
  531.  
  532. ;enter with si -> argument string, di -> wword to store.
  533. ;if there is no number, don't change the number.
  534.     extrn    get_number: near
  535.  
  536. ;enter with dx -> argument string, di -> wword to print.
  537.     extrn    print_number: near
  538.  
  539.     public    parse_args
  540. parse_args:
  541. ;exit with nc if all went well, cy otherwise.
  542.     clc
  543.     ret
  544.  
  545.  
  546. signature    db    "TELESYSTEM"
  547. signature_len    equ    $-signature
  548.  
  549. no_board_msg    db    "Cannot locate an ARLAN board.",'$'
  550. self_test_msg    db    "ARLAN board self-tests bad.",'$'
  551. bad_mem_msg    db    "The on-card memory tests as bad.",'$'
  552. file_not_found    db    "File not found",'$'
  553. read_trouble    db    "Trouble reading the file",'$'
  554. timeout_msg_xx    db    "x"
  555. timeout_msg_x    db    "x"
  556. timeout_msg    db    "Timed out waiting for the board",'$'
  557. configure_bad    db    "The configure attempt failed",'$'
  558.  
  559. arlan_cfg    db    "arlan.cfg",0
  560. handle        dw    ?
  561.  
  562. int_no_name    db    "Interrupt number ",'$'
  563.  
  564.     public    etopen
  565. etopen:
  566.     assume    ds:code, es:arlan_segment
  567.  
  568. ;look for the arlan card in memory
  569.     mov    dx,0c000h
  570. etopen_1:
  571.     mov    si,offset signature
  572.     mov    es,dx
  573.     mov    di,offset ar_signature
  574.     mov    cx,signature_len
  575.     repe    cmpsb
  576.     je    etopen_2
  577.  
  578.     add    dx,200h
  579.     cmp    dx,0de00h
  580.     jb    etopen_1
  581.     mov    dx,offset no_board_msg
  582.     jmp    error
  583. etopen_2:
  584.     mov    base_addr,dx
  585.  
  586.     mov    ar_control,1        ;reset the board.
  587.  
  588.     mov    ax,base_addr        ;test the memory.
  589.     mov    cx,2000h-3
  590.     call    memory_test
  591.     je    memory_ok
  592.     mov    dx,offset bad_mem_msg
  593.     jmp    error
  594. memory_ok:
  595.  
  596.     xor    di,di            ;zero all the memory.
  597.     mov    cx,2000h-1
  598.     xor    al,al
  599.     rep    stosb
  600.  
  601.     mov    ar_reset,1        ;set the reset flag.
  602.     mov    ar_control,0        ;remove the reset.
  603.  
  604.     mov    ax,36
  605.     call    set_timeout
  606. wait_for_reset:
  607.     cmp    ar_reset,0        ;did it finish resetting yet?
  608.     je    wait_for_reset_1    ;yes, exit.
  609.     call    do_timeout
  610.     jne    wait_for_reset
  611.     mov    dx,offset timeout_msg
  612.     jmp    error
  613. wait_for_reset_1:
  614.  
  615. ;set the reset flag again, so that we can detect if we somehow got reset.
  616.  
  617.     mov    ar_reset,1
  618.  
  619.     cmp    ar_diagnostics,0ffh    ;Did it self-check okay?
  620.     je    self_test_ok
  621.     mov    dx,offset self_test_msg
  622.     jmp    error
  623. self_test_ok:
  624.  
  625.     mov    ar_command,COM_NOP    ;do a NOP.
  626.     call    doca
  627.     jnc    wait_for_first_nop_1
  628.     mov    dx,offset self_test_msg
  629.     jmp    error
  630. wait_for_first_nop_1:
  631.  
  632. ;;; They say to do another with with COM_INT set...
  633.  
  634.     mov    al,ar_irq_level        ;copy the interrupt number out of
  635.     mov    int_no,al        ;  the configuration file.
  636.  
  637.     mov    ax,3d00h        ;open for reading.
  638.     mov    dx,offset arlan_cfg
  639.     int    21h
  640.     jnc    file_found
  641.     mov    dx,offset file_not_found
  642.     jmp    error
  643.  
  644. file_found:
  645.     mov    handle,ax
  646.  
  647.     mov    ax,4200h
  648.     mov    bx,handle
  649.     xor    cx,cx
  650.     mov    dx,100h            ;skip past the first 100h bytes.
  651.     int    21h
  652.  
  653.     mov    ah,3fh            ;read the system parameters.
  654.     mov    bx,handle
  655.     mov    cx,100h
  656.     mov    dx,offset ar_sys_params
  657.     push    ds
  658.     mov    ds,base_addr
  659.     int    21h
  660.     pop    ds
  661.     jnc    no_trouble
  662.     mov    dx,offset read_trouble
  663.     jmp    error
  664.  
  665. no_trouble:
  666.  
  667.     mov    ah,3eh            ;close the file.
  668.     mov    bx,handle
  669.     int    21h
  670.  
  671.     cmp    int_no,0        ;Does the board know its interrupt
  672.     jne    set_int_no        ;  number?  go if it does.
  673.     mov    al,ar_irq_level        ;No, so use the one
  674.     mov    int_no,al        ;  in the configuration file.
  675. set_int_no:
  676.  
  677. ; do the configure.
  678.  
  679.     mov    ar_command,COM_CONF
  680.     call    doca
  681.     jnc    wait_for_configure_1    ;it did.
  682.     mov    dx,offset timeout_msg_x
  683.     jmp    error
  684. wait_for_configure_1:
  685.  
  686.     cmp    ar_diagnostics,0ffh    ;did the configure succeed?
  687.     je    configure_ok
  688.     mov    dx,offset configure_bad
  689.     jmp    error
  690. configure_ok:
  691.  
  692. ;wait a short while for the AR450.  For the AR440, wait up to 15 seconds.
  693.  
  694.     mov    ax,36
  695.     call    set_timeout
  696. wait_for_address:
  697.     mov    cx,EADDR_LEN        ;see if our address is still zeroes.
  698.     mov    si,offset ar_node_id
  699.     xor    al,al
  700. wait_for_address_2:
  701.     or    al,es:[si]
  702.     inc    si
  703.     loop    wait_for_address_2
  704.     or    al,al            ;do we have an address yet?
  705.     jne    wait_for_address_1    ;yes.
  706.     call    do_timeout
  707.     jne    wait_for_address
  708.     mov    dx,offset timeout_msg_xx
  709.     jmp    error
  710. wait_for_address_1:
  711.  
  712. ;say that the max we'll send is an Ethernet GIANT packet, less the two
  713. ;  Ethernet addresses that we don't include in the datagram, plus the one
  714. ;  broadcast byte that we *do* include.
  715.  
  716.     mov    ax,GIANT - EADDR_LEN*2 + 1
  717.     mov    ax,1023
  718.     mov    ar_MDS,ax
  719.     mov    ar_MFS,ax
  720.  
  721. ; reduce the number of retries
  722.  
  723.     mov    ar_max_retry,16
  724.  
  725. ;enable reception
  726.  
  727.     call    enable_receive
  728.  
  729. ;mark transmission as done
  730.  
  731.     mov    ar_tx_status,1
  732.  
  733. ;enable our interrupts.
  734.  
  735.     mov    al,ar_control_i
  736.     or    al,CONTROL_IE or CONTROL_CLRI
  737.     mov    ar_control_i,al
  738.     mov    ar_control,al
  739.  
  740. ; Now hook in our interrupt
  741.  
  742.     call    set_recv_isr
  743.  
  744.     sti
  745.  
  746.     mov    al, int_no        ; Get board's interrupt vector
  747.     add    al, 8
  748.     cmp    al, 8+8            ; Is it a slave 8259 interrupt?
  749.     jb    set_int_num        ; No.
  750.     add    al, 70h - 8 - 8        ; Map it to the real interrupt.
  751. set_int_num:
  752.     xor    ah, ah            ; Clear high byte
  753.     mov    int_num, ax        ; Set parameter_list int num.
  754.  
  755.     mov    dx,offset end_resident
  756.     clc
  757.     ret
  758.  
  759.  
  760.     public    print_parameters
  761. print_parameters:
  762. ;echo our command-line parameters
  763.     mov    dx,offset int_no_name
  764.     mov    di,offset int_no
  765.     call    print_number
  766.  
  767.     ret
  768.  
  769.     include    memtest.asm
  770.  
  771. code    ends
  772.  
  773.     end
  774.